package com.superbytecode.cloud.web.swagger;

import com.superbytecode.cloud.common.context.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

import java.net.InetAddress;
import java.util.Optional;
/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: beacon-cloud
 * @Package: com.superbytecode.cloud.web.swagger
 * @ClassName: SwaggerConsole
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2024/10/22 12:02
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Slf4j
public class SwaggerConsole implements ApplicationRunner {
    /**
     * @param args 参数
     * @throws Exception 异常
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        String applicationName = SpringContextUtil.getProperty("spring.application.name");
        String contextPath = Optional.ofNullable(SpringContextUtil.getProperty("server.servlet.context-path")).orElse("");
        String host = InetAddress.getLocalHost().getHostAddress();
        String port = Optional.ofNullable(SpringContextUtil.getProperty("server.port")).orElse("8080");
        String profile = SpringContextUtil.getProfile();
        log.info("\n"//
                        + "----------------------------------------------------------\n"//
                        + "\t Application: '{}' is running! \n" //
                        + "\t Environment:  {} \n" //
                        + "\t Swagger Doc:  http://{}:{}{}/doc.html \n" //
                        + "----------------------------------------------------------\n",//
                applicationName, profile, host, port, contextPath);
    }
}